PayPal and SSL baby! And blog pagination function?

by: kingfitz, 8 years ago


Yo Harrison

Just popping in! I just got SSL configured properly after a real bitch of week. It turns out the configuration isn't that streamlined for most people and I tried both the running from source method like you did and the sudo apt-get install python-letsencrypt-apache package method but every time it was configured improperly somehow.  Finally figured out after much trial and tribulation, I'll post the tips here below for reference.  

# working Apache2 mod-wsgi SSL configuration with letsencrypt   -   use this line to renew: ./letsencrypt-auto --apache -d yourdomain -d www.yourdomain

# notes:  had to add this part to line: WSGIDaemonProcess in flask.conf,
user= youruser group=www-data processes=1 threads=2    and copy all directives to the 443 vhost (the one let's encrypt auto generated).  Upon making changes to a vhost you have to disable and reenable it. Also use the certificate renewal command to refresh configuration.  Check 000-default.conf for redundancies if needed.  

I got PayPal integration and SSL and now implemented and it feels fucking awesome, I owe it all to you.   By the way for PayPal I have some tips for you in case you didn't know.  After experimenting with buttons I figured out the PayPal has invoices which are actually more convenient and more flexible so that is what I'm going to use.

What you want to do is create the buttons within PayPal's interface and not leave parameters of the payment in plain HTML, for security reasons.  When you create them through their interface the buttons are encrypted on your site which is pretty cool. You can also add additional parameters within their interface at the bottom of the button creation page.  So you have to go into your developer.PayPal.com Account create a second sandbox account apart from the original default one.  Set up a basic test facilitator and test buyer, then you login as the facilitator at sandbox.PayPal.com,   Go to merchant services, look for create button.  Choose and create a button, copy your buttons code to your website.  Then login as the test buyer and click the button and you done voila.  You can also send invoices from your test seller and do the same thing.  It's crazy e-commerce couldn't be easier integrated.   And I am in amateur.  The way I'm going to deal with customers is basically they register, login, go to purchase, click on an item, takes them to a detailed form, submits the form both to me and them, after I see the form I email them an invoice.   All the payment information and their personal information remain with PayPal and therefore I don't have to deal with that worry about it or more importantly be liable for their information.  

BTW I was also curious if you have a simple snippet for pagination for a blog in flask?  Would it be involved with URL converters as you discussed in the tutorial?

Anyways things are looking up for New Year hope the same for you thanks brother catch you later.



You must be logged in to post. Please login or register an account.



Bummer to hear your troubles with SSL. With letsencrypt on apache, I've put it on about 7 Flask sites and helped a few clients, and it's always been a breeze. I wonder why you had so much issue! I have never needed to make the changes you described above. I'll keep this in mind if it gives me trouble.

What version of Python and Flask are you using? Maybe it's a new thing that I'll come across soon!

Yeah! PayPal is great! Careful with custom invoicing. Yes, it does get encrypted and verified, but people can still fool around.

I always verify directly IPN after a payment and confirm the amounts that way. Aside from charging me back later, I can know 100% what you paid me. No one has spoofed me yet on this site, but I run another website where people have tried all sorts of foolery.

PayPal sandbox is absolutely top notch. I love that they supplied it, was super helpful to me when starting out, and it *realllllly* is just a change of a few addresses to make it live, everything else is identical. You have to really give PayPal props for doing that right.

I do not know of any super simple pagination for blogs. Flask probably has a pagination extension, but, with Flask, I just write everything myself...it's part of the fun to me.

I'll reference how I did these community forums:

The route:

@app.route('/community/', methods=['GET', 'POST'])
@app.route('/community/page/<page>/', methods=['GET', 'POST'])


Then I have "threads per page," which I elect to be 10.

Then I just grab thread ids in descending time order, and sort them into a list of lists, where it's a list of lists, where the lists contain 10 desc ordered thread ids..

<page> - 1 is the index [0], page 2 is index [1]...and so on. Someone loads up that page, and then that index of thread ids  from that list of lists is pulled from the database for view.

Hope that helps. I should definitely put out a pagination with Flask tutorial.




-Harrison 8 years ago

You must be logged in to post. Please login or register an account.


I am using the latest Python3.5.2 and the latest flask 0.12.  I think the issue with let's encrypt is I was using an ubuntu package, not the package from source which is more recent, so they probably sorted out a few bugs.  Either way I know exactly how to configure the Apache files for SSL now.  You can go back in and examine how let's encrypt configured them automatically.

Also I could never get your IPN function to successfully process, so I had to abandon it, although I would still like to be able to use it.  Maybe I will test it couple more times.

Anyways I am pretty stoked, SSL, PayPal, and I just added my SEO function for sitemap.xml and robot.txt. One thing I want to add to that SEO function is h1-4 tag processing for headlines.  Should help.   Also one tip I found for a cheap digital ocean server, or any server with under 2-3 GB of RAM, should use 32-bit, since 64-bit Applications use much more memory, there isn't much benefit using a 64-bit Ubuntu on a serverwith .5 five GB of RAM.  I use ubuntu 16.04 32-bit now and everything is very smooth.  Anyways catch you later thanks.

-kingfitz 8 years ago
Last edited 8 years ago

You must be logged in to post. Please login or register an account.